import request from '../../http'

const URL = {
	LOGIN: '/wx_login',
	LOGOUT: '/wx_logout',
	SALARYTYPE_SELECT: '/salaryType/select',
	SALARYTYPE_INSERT: '/salaryType/insertCustom',
	SALARYTYPE_DELETE: '/salaryType/delete',
	THANKS_SELECT: '/thanks/select',
	THANKS_INSERT: '/thanks/insertCustom',
	THANKS_DELETE: '/thanks/delete',
	PAYROLL_SET_INFO: '/payrollSet/selectInfo',
	PAYROLL_SET_EDIT: '/payrollSet/edit',
	PAYROLL_CONFIRM_REMINDER_ADD: '/payrollConfirmReminder/add',
	PAYROLL_CONFIRM_REMINDER_EDIT: '/payrollConfirmReminder/edit',
	PAYROLL_CONFIRM_REMINDER_REMOVE: '/payrollConfirmReminder/remove',
	PAYROLL_GRANT_REMINDER_ADD: '/payrollGrantReminder/add',
	PAYROLL_GRANT_REMINDER_EDIT: '/payrollGrantReminder/edit',
	PAYROLL_GRANT_REMINDER_REMOVE: '/payrollGrantReminder/remove',
	PAYROLL_ADD_SAVE: '/payroll/addSave',
	PAYROLL_LIST: '/payroll/getList',
	PAYROLL_VERIFY_REMOVE: '/payroll/verifyRemove',
	PAYROLL_REMOVE: '/payroll/remove',
	PAYROLL_RECORDS: '/payroll/payrollRecords',
	PAYROLL_SELECT_H5: '/payroll/selectH5',
	PAYROLL_DETAILS_LIST: '/payrollDetails/list',
	PAYROLL_DETAILS_SEND: '/payrollDetails/send',
	PAYROLL_DETAILS_SEND_ALL: '/payrollDetails/sendAll',
	PAYROLL_DETAILS_WITHDRAW: '/payrollDetails/withdraw',
	PAYROLL_DETAILS_WITHDRAW_ALL: '/payrollDetails/withdrawAll',
	PAYROLL_DETAILS_GETDATA: '/payrollDetails/getData',
	PAYROLL_DETAILS_UPDATA: '/payrollDetails/upData',
	PAYROLL_DETAILS_EXPORT: '/payrollDetails/export',
	PAYROLL_MODIFY_HISTORY: '/payrollModifyHistory/mapList'
}

export const userLogin = ({ code, state }) => request(URL.LOGIN, 'POST', { code, state })

export const userLogout = () => request(URL.LOGOUT, 'POST')

// 薪资类型查询
export const postSalaryTypeSelect = () => request(URL.SALARYTYPE_SELECT, 'POST')

// 薪资类型添加
export const postSalaryTypeInsert = ({ sstName }) =>
	request(URL.SALARYTYPE_INSERT, 'POST', { sstName })

// 薪资类型删除
export const postSalaryTypeDelete = ({ sstId }) => request(URL.SALARYTYPE_DELETE, 'POST', { sstId })

// 薪资类型查询
export const postThanksSelect = () => request(URL.THANKS_SELECT, 'POST')

// 薪资类型添加
export const postThanksInsert = ({ thanks }) => request(URL.THANKS_INSERT, 'POST', { thanks })

// 薪资类型删除
export const postThanksDelete = ({ id }) => request(URL.THANKS_DELETE, 'POST', { id })

// 工资条设置查询
export const postPayrollSetInfo = () => request(URL.PAYROLL_SET_INFO, 'POST')

// 工资条设置修改
export const postPayrollSetFeedbackSettings = ({ feedbackSettings }) =>
	request(
		URL.PAYROLL_SET_EDIT,
		'POST',
		{ feedbackSettings },
		{ headers: { 'Content-Type': 'application/json;charset=UTF-8' } }
	)

export const postPayrollSetAutoConfirmationSettings = ({ autoConfirmationSettings }) =>
	request(
		URL.PAYROLL_SET_EDIT,
		'POST',
		{ autoConfirmationSettings },
		{ headers: { 'Content-Type': 'application/json;charset=UTF-8' } }
	)

export const postPayrollSetAutoConfirmationDays = ({ autoConfirmationDays }) =>
	request(
		URL.PAYROLL_SET_EDIT,
		'POST',
		{ autoConfirmationDays },
		{ headers: { 'Content-Type': 'application/json;charset=UTF-8' } }
	)

// 工资条确认提醒
export const postPayrollConfirmReminderAdd = ({ days }) =>
	request(URL.PAYROLL_CONFIRM_REMINDER_ADD, 'POST', { days })

export const postPayrollConfirmReminderEdit = ({ spcrId, reminderDay }) =>
	request(
		URL.PAYROLL_CONFIRM_REMINDER_EDIT,
		'POST',
		{ spcrId, reminderDay },
		{ headers: { 'Content-Type': 'application/json;charset=UTF-8' } }
	)

export const postPayrollConfirmReminderRemove = ({ ids }) =>
	request(URL.PAYROLL_CONFIRM_REMINDER_REMOVE, 'POST', { ids })

// 工资条发放提醒
export const postPayrollGrantReminderAdd = ({ monthlyWageDays, reminderDay }) =>
	request(
		URL.PAYROLL_GRANT_REMINDER_ADD,
		'POST',
		{ monthlyWageDays, reminderDay },
		{ headers: { 'Content-Type': 'application/json;charset=UTF-8' } }
	)

export const postPayrollGrantReminderEdit = ({ spcrId, monthlyWageDays, reminderDay }) =>
	request(
		URL.PAYROLL_CONFIRM_REMINDER_EDIT,
		'POST',
		{ spcrId, monthlyWageDays, reminderDay },
		{ headers: { 'Content-Type': 'application/json;charset=UTF-8' } }
	)

export const postPayrollGrantReminderRemove = ({ ids }) =>
	request(URL.PAYROLL_CONFIRM_REMINDER_REMOVE, 'POST', { ids })

// 工资条添加
export const postPayrollAddSave = ({
	sendHeader,
	burnAfterReading,
	sendingMethod,
	salaryMonth,
	salaryType,
	thanksStart,
	thanksEnd,
	warmTips,
	whetherToSend,
	hideEmpty,
	hideZero
}) =>
	request(
		URL.PAYROLL_ADD_SAVE,
		'POST',
		{
			sendHeader,
			burnAfterReading,
			sendingMethod,
			salaryMonth,
			salaryType,
			thanksStart,
			thanksEnd,
			warmTips,
			whetherToSend,
			hideEmpty,
			hideZero
		},
		{ headers: { 'Content-Type': 'application/json;charset=UTF-8' } }
	)

// 工资条查询
export const postPayrollList = ({ salaryTitle, sendStartTime, sendEndTime, pageNum, pageSize }) =>
	request(
		URL.PAYROLL_LIST,
		'POST',
		{ salaryTitle, sendStartTime, sendEndTime, pageNum, pageSize },
		{ headers: { 'Content-Type': 'application/json;charset=UTF-8' } }
	)

// 删除校验
export const postPayrollVerifyRemove = ({ id }) =>
	request(URL.PAYROLL_VERIFY_REMOVE, 'POST', { id })

// 工资条删除
export const postPayrollRemove = ({ id }) => request(URL.PAYROLL_REMOVE, 'POST', { id })

// 工资条详情
export const postPayrollDetailsList = ({ id, pageNum, pageSize }) =>
	request(URL.PAYROLL_DETAILS_LIST, 'POST', { id, pageNum, pageSize })

// 工资条发送
export const postPayrollDetailsSend = ({ spdId, spmId }) =>
	request(URL.PAYROLL_DETAILS_SEND, 'POST', { spdId, spmId })

// 工资条全部发送
export const postPayrollDetailsSendAll = ({ spmId }) =>
	request(URL.PAYROLL_DETAILS_SEND_ALL, 'POST', { spmId })

// 工资条撤回
export const postPayrollDetailsWithdraw = ({ spdId, spmId }) =>
	request(URL.PAYROLL_DETAILS_WITHDRAW, 'POST', { spdId, spmId })

// 工资条全部撤回
export const postPayrollDetailsWithdrawAll = ({ spmId }) =>
	request(URL.PAYROLL_DETAILS_WITHDRAW_ALL, 'POST', { spmId })

// 查看员工工资条详情
export const postPayrollDetailsGetData = ({ spmId, userAccount, importType }) =>
	request(URL.PAYROLL_DETAILS_GETDATA, 'POST', { spmId, userAccount, importType })

// 更新员工工资条详情
export const postPayrollDetailsUpData = ({
	spmId,
	userAccount,
	importType,
	payrollParseVos = []
}) =>
	request(
		URL.PAYROLL_DETAILS_UPDATA,
		'POST',
		{ spmId, userAccount, importType, payrollParseVos },
		{ headers: { 'Content-Type': 'application/json;charset=UTF-8' } }
	)

// // 导出工资条详情
// export const postPayrollDetailsExport = ({ ids, spmId }) =>
// 	request(URL.PAYROLL_DETAILS_EXPORT, 'POST', { ids, spmId })

// 获取工资条相关信息
export const postPayrollSelectH5 = ({ spmId, userAccount }) =>
	request(URL.PAYROLL_SELECT_H5, 'POST', { spmId, userAccount })

// 获取工资条相关信息
export const postPayrollRecords = () => request(URL.PAYROLL_RECORDS, 'POST')

// 获取工资条修改历史
export const postPayrollModifyHistory = ({ spmId }) =>
	request(URL.PAYROLL_MODIFY_HISTORY, 'POST', { spmId })
